import { GameRule, RallyRule, Stage, Tournament } from "@/championship";
import { http, httpGet, httpPost, httpDelete } from "@/utils/http";

export const createStage = async (data: Stage): Promise<IResData<Stage>> => {
  // const res = await httpPost<Stage>('/stage', data)
  const res = await httpPost<Stage>("/stage/stageCreate", data);

  return res;
};

export const getStageDetail = async (id: string): Promise<IResData<Stage>> => {
  const res = await httpGet<Stage>(`/stage/getDetail`, {
    id,
  });
  return res.data;
};

export const removeById = async (id: string): Promise<IResData<any>> => {
  const res = await httpGet(`/common/deleteStage`, { id });
  return res;
};

export const getGameRules = async (): Promise<IResData<GameRule[]>> => {
  const res = await httpGet<GameRule[]>("/game-rule/list");
  return res;
};

export const getRallyRules = async (): Promise<IResData<RallyRule[]>> => {
  const res = await httpGet<RallyRule[]>("/rally-rule/list");
  return res;
};

export const getStageMatchesByStageId = async (
  stageId: string,
): Promise<IResData<Stage>> => {
  const res = await httpGet<Stage>(`/stage/getStageMatches`, {
    stageId,
  });
  return res;
};
